package com.omazan.srvlts;

import java.io.IOException;
import java.io.PrintWriter;

import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.omazan.ejb.Test;

/**
 * Servlet implementation class Test
 */
@WebServlet("/TestServlet")
public class TestServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public TestServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

//    @EJB
//    Test test;
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
		    InitialContext ctx = new InitialContext();
		   Test test = (Test)ctx.lookup("java:comp/env/MyStatefulBean");
		    PrintWriter out = response.getWriter();
		    out.println(test.hello());
		} catch (Exception e) {
		    // exception handling
		}
	}

}
